package com.xjlsoft.weather.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xjlsoft.weather.po.Result;

import io.swagger.annotations.Api;

@Controller
@Api(tags = "测试  接口")
public class IndexController {
	 @RequestMapping("/")
	    public String index()  {
	        return "index";
	    }

	    @PostMapping("/user")
	    @RequiresRoles(value = {"admin"})
	    @ResponseBody
	    public Result user(){
	        return new Result(200,"成功访问user接口！");
	    };

	    @PostMapping("/admin")  //需要 admin角色  才能访问
	    @RequiresPermissions(value = { "task:update"})   //需要该权限 才能访问
	    @ResponseBody
	    public Object admin() {
	        return new Result(200,"成功访问admin接口！");
	    };

}
